-
Notifications
You must be signed in to change notification settings - Fork 864
.NET: fix: RunState is sometimes Running when it should be Idle #2646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where RunStatus was incorrectly set to Running when the workflow had no work to do. The fix ensures the Running state is only set when messages are actually being processed.
Key Changes:
- Moved
RunStatus.Runningassignment from before the message processing loop to inside the loop where actual work happens - Removed premature state changes that occurred after timeout waits, ensuring state reflects actual execution status
| this._runStatus = RunStatus.Running; // Ensure we do not inappropriately signal Running status unless | ||
| // messages are being processed. |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RunStatus.Running state and state transitions during workflow execution lack test coverage. While tests verify Idle, PendingRequests, and Ended states, no tests verify that the Running state is correctly set during execution or that it correctly transitions to other states. Consider adding a test that verifies:
- The status is
Runningwhile messages are being processed - The status correctly transitions to
IdleorPendingRequestsafter processing completes - The status is not
Runningwhen there are no messages to process (the bug being fixed here)
There is a timeout-wait for messages in the inner loop driving the running of the workflow. When it gets cleared, an attempt to run a superstep is made. Currently we set the state to running as soon as the wait clears, even if we have no work to do, and clear it upon discovering this. The fix is to only set the Running state when actual Workflow execution is happening when running Super-Steps, and not until the loop confirms there is work to do. A broader-term fix would be to remove the Semaphore and timeout-wait in it, since it is working around the inability to atomicaly insert and release the Semaphore,
4c4e193 to
efbb023
Compare
Motivation and Context
There is a timeout-wait for messages in the inner loop driving the running of the workflow. When it gets cleared, an attempt to run a superstep is made. Currently we set the state to running as soon as the wait clears, even if we have no work to do, and clear it upon discovering this.
This causes a sporadic UnitTest failure in Workflows.
Description
The fix is to only set the Running state when actual Workflow execution is happening when running Super-Steps, and not until the loop confirms there is work to do.
TODO: A broader-term fix would be to remove the Semaphore and timeout-wait in it, since it is working around the inability to atomically insert and release the Semaphore driving the wait. The timeout provides a race condition where the workflow was "ghosting" a Running status. See #2647
Contribution Checklist
Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.